﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Theme_1_UserControls_ShowUserLogin : System.Web.UI.UserControl
{
    PowerCreator.LMS.Web.User.User opUser = new PowerCreator.LMS.Web.User.User();
    protected PowerCreator.LMS.Web.Config.WebConfig config = new PowerCreator.LMS.Web.Config.WebConfig();
    private PowerCreator.LMS.Web.DL.User.LoginEntity login = new PowerCreator.LMS.Web.DL.User.LoginEntity();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitPage();
        }

        if (Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO] == null)
        {
            pl_UserLogin.Visible = true;
            pl_UserInfo.Visible = false;
        }
        else
        {
            pl_UserLogin.Visible = false;
            pl_UserInfo.Visible = true;
            PowerCreator.LMS.Web.User.LoginEntity login = (PowerCreator.LMS.Web.User.LoginEntity)Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO];
            lbl_UserName.Text = login.UserName.Trim();
            lbl_UserReal.Text = login.AccountInfo.RealName.Trim();
        }
    }
    private void InitPage()
    {
        btn_Login.Text = config.GetLanagerValueByKey("SysManagerLogin", PowerCreator.LMS.Language.LanagetItemType.Page);
        btn_LoginOut.Text = config.GetLanagerValueByKey("SysManagerOutLogin", PowerCreator.LMS.Language.LanagetItemType.Page);
        btn_Registor1.Text = config.GetLanagerValueByKey("SysManagerRegistor", PowerCreator.LMS.Language.LanagetItemType.Page);
    }

    private bool CheckPage()
    {
        return true;
    }
    protected void btn_Login_Click(object sender, EventArgs e)
    {
        //转到首页登录
        string url = "Default.aspx";
        PowerCreator.LMS.Common.Script.Script.RedirectURL(url);
        
    }
    protected void btn_LoginOut_Click(object sender, EventArgs e)
    {
        PowerCreator.LMS.Web.User.User opUser = new PowerCreator.LMS.Web.User.User();
        if (Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO] != null)
        {
            login = (PowerCreator.LMS.Web.DL.User.LoginEntity)Session[PowerCreator.LMS.Web.Config.WebConfig.SESSION_USER_USERINFO];
            if (login != null)
                opUser.UpdateOnlineUserByUserID(login.VOLearner.Learner_Id, 2);
        }

        Session.Abandon();
        PowerCreator.LMS.Common.Script.Script.ReloadMe();
    }
    protected void btn_Registor_Click(object sender, EventArgs e)
    {
        PowerCreator.LMS.Common.Script.Script.RedirectURL("Register.aspx");
    }
    protected void btn_Registor1_Click(object sender, EventArgs e)
    {
        PowerCreator.LMS.Common.Script.Script.RedirectURL("Register.aspx");
    }
}
